package com.mahees.portfolio.service

import com.mahees.portfolio.domain.SoftwareProject;

class ProjectService {

    static transactional = true

    def saveSoftwareProject(SoftwareProject softwareProject, def hasManyOptions) {
		softwareProject.save(failOnError : true);
				
		hasManyOptions.developmentTools?.each {
			softwareProject.addToDevelopmentTools(it)
		}
    }
	
	def updateSoftwareProject(SoftwareProject softwareProject, def hasManyOptions) {
		softwareProject.save(failOnError : true);
		
		softwareProject.developmentTools.clear()
		//softwareProject.developmentTools*.delete(failOnError: true)
		
		hasManyOptions.developmentTools?.each {
			softwareProject.addToDevelopmentTools(it)
		}
	}
}
